home *** CD-ROM | disk | FTP | other *** search
/ JCSM Shareware Collection 1993 November / JCSM Shareware Collection - 1993-11.iso / cl720 / sst115j.lzh / SSTMSC.C < prev    next >
C/C++ Source or Header  |  1992-01-28  |  3KB  |  105 lines

  1. /* ------------------------------------------------------------------------ */
  2. /*                                sstmisc.c                                 */
  3. /*                                                                          */
  4. /*                    low-level miscellaneous functions                     */
  5. /*                                                                          */
  6. /*      CopyRight (C) 1991,1992  Steven Lutrov.   All rights reserved.      */
  7. /* ------------------------------------------------------------------------ */
  8.  
  9. #include <stdio.h>
  10. #include <dos.h>
  11.  
  12. #include "sstwin.h"
  13.  
  14.  
  15. /* ------------------------------------------------------------------------ */
  16. /*                   puts the current date out to the screen                */
  17. /*      1 = dd-mm-yy       2 = dd mmm yyyy   3 = mm-dd-yy    4 = yy-mm-dd      */
  18. /* ------------------------------------------------------------------------ */
  19. void mscputdate(int x, int y, int attr, int fmt )
  20. {
  21.   char *MonthArray[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  22.                "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
  23.   struct date dt;
  24.  
  25.   getdate(&dt);
  26.   switch(fmt) {
  27.      case 1:
  28.          vputf(x, y, attr,"%2d-%02d-%02d", dt.da_day, dt.da_mon,
  29.            dt.da_year % 100 );
  30.          break;
  31.      case 2:
  32.          vputf(x, y, attr,"%2d %3s %04d", dt.da_day,
  33.            MonthArray[dt.da_mon-1], dt.da_year );
  34.          break;
  35.      case 3:
  36.          vputf(x, y, attr,"%02d-%2d-%02d", dt.da_mon, dt.da_day,
  37.            dt.da_year % 100 );
  38.          break;
  39.      case 4:
  40.          vputf(x, y, attr,"%02d-%02d-%2d", dt.da_year % 100 , dt.da_mon,
  41.            dt.da_day);
  42.          break;
  43.     }
  44. }
  45.  
  46. /* ------------------------------------------------------------------------ */
  47. /*                     puts the current time onto the screen                */
  48. /*                 1 = hh:mm:ss (military)   2 = hh:mm    (military)          */
  49. /*           3 = hh:mm:ss AM/PM        4 = hh:mm    AM/PM               */
  50. /* ------------------------------------------------------------------------ */
  51. void mscputtime(int x, int y, int attr, int fmt)
  52. {
  53.    struct time tm;
  54.    char c;
  55.  
  56.    gettime(&tm);
  57.    switch(fmt) {
  58.     case 1:
  59.         vputf(x, y, attr,"%2d:%02d:%02d",
  60.             tm.ti_hour, tm.ti_min, tm.ti_sec );
  61.         break;
  62.     case 2:
  63.         vputf(x, y, attr,"%2d:%02d",tm.ti_hour, tm.ti_min );
  64.         break;
  65.     case 3:
  66.         c = 'A';
  67.         if ( tm.ti_hour > 11 ) {
  68.             c = 'P';
  69.             tm.ti_hour -= 12;
  70.         }
  71.         if ( tm.ti_hour == 0 )  tm.ti_hour = 12;
  72.         vputf(x, y, attr,"%2d:%02d:%02d %cM",
  73.             tm.ti_hour, tm.ti_min, tm.ti_sec, c );
  74.         break;
  75.     case 4:
  76.         c = 'A';
  77.         if ( tm.ti_hour > 11 ) {
  78.             c = 'P';
  79.             tm.ti_hour -= 12;
  80.         }
  81.         if ( tm.ti_hour == 0 )  tm.ti_hour = 12;
  82.         vputf(x, y, attr,"%2d:%02d %cM",
  83.             tm.ti_hour, tm.ti_min, c );
  84.         break;
  85.    }
  86. }
  87.  
  88. /* ------------------------------------------------------------------------ */
  89. /*                           makes a beep noise                             */
  90. /* ------------------------------------------------------------------------ */
  91. void mscbeep(int m)
  92. {
  93.    if (m)    {
  94.      sound(2000);
  95.      delay(100);
  96.    }
  97.    else {
  98.     sound(500);
  99.     delay(250);
  100.   }
  101.  nosound();
  102. }
  103.  
  104.  
  105.